{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}会员专区 - {{ parent() }}{% endblock %}
{% set script_controller = 'vipbundle/controller/vip/memberzone' %}

{% block content %}
<div class="es-row-wrap container-gap">
  <div class="row">
    <div class="col-md-12">
      <div class="page-header"><h1>会员专区</h1></div>
    </div>
    <div class="col-md-3">
      {% if app.user %}
        <div class="media mbl">
          <a href="{{ path('user_show', {id:app.user.id}) }}" class="pull-left">
            <img class="author-picture" src="{{ file_path(app.user.mediumAvatar, 'avatar.png') }}" width="100">
          </a>
          <div class="media-body">
            <h5 class="media-heading"><a href="{{ path('user_show', {id:app.user.id}) }}">{{ app.user.nickname }}</a></h5>
            {% if userVip %}
            <p>
              {% for level in levels %}
                {% if level.id == userVip.levelId %}
                  <img src="{{ asset(level.icon|default('assets/img/default/vip-icon-default.png')) }}" alt="{{ level.name }}" title="{{ level.name }}" >
                {% endif %}
              {% endfor %}
            </p>
            <p>
              <small class="text-primary">{{ userVip.deadline|date('Y-m-d') }}到期</small>
              <br>
              {% if userVip.deadline < nowTime %}
                <small class="text-danger">会员已过期</small>
              {% else %}
                <small class="text-muted">剩余{{ userVip.deadline|remain_time }}</small>
              {% endif %}
            </p>
            {% else %}
              <p class="mtm"><small class="text-muted">您还不是会员，请先开通会员</small></p>
            {% endif %}
          </div>
        </div>

        {% if userVip %}
          {% if userVip.deadline|remain_time < 7 and userVip.deadline|remain_time > 0 %}
            {% if deadlineAlertCookie == null %}
              <div class="alert alert-danger fade in">
                <button type="button" id ="deadlineAlert" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <small>您的会员即将到期，请及时续费哦。</small>
              </div>
            {% endif %}
          {% endif %}
        {% endif %}
        <div class="list-group">
          <a class="list-group-item {% if menu == 'index' %}active{% endif %}" href="{{ path('vip') }}">会员专区</a>
          {% if userVip %}
            <a class="list-group-item" href="{{ path('vip_upgrade') }}">升级会员</a>
            <a class="list-group-item" href="{{ path('vip_renew') }}">会员续费</a>
          {% else %}
            <a class="list-group-item" href="{{ path('vip_buy') }}">开通会员</a>
          {% endif %}
          <a class="list-group-item {% if menu == 'history' %}active{% endif %}" href="{{ path('vip_history') }}">购买历史</a>
        </div>  
      {% else %}
        <div class="well">
          <h4>欢迎来到会员专区</h4>
          <p><a class="btn btn-block btn-lg btn-primary" href="{{ path('login') }}">用户登录</a></p>
          <p class="text-muted">没有帐号？ <a href="{{ path('register') }}">用户注册</a></p>
        </div>
      {% endif %}
      <div class="es-box">
        <div class="es-box-heading"><h2>最新会员</h2></div>
        <ul class="media-list lastest-member-list">
          {% if latestMembers %}
            {% for latestMember in latestMembers %}
            <li class="media">
              <a href="{{ path('user_show', {id:latestMember.id}) }}" class="member-picture-link">
                <img class="member-picture" src="{{ file_path(latestMember.smallAvatar, 'avatar.png') }}" class="media-object">
              </a>
              <div class="media-body">
                <h5 class="media-heading"><a class="member-nickname ellipsis" href="{{ path('user_show', {id:latestMember.id}) }}">{{ latestMember.nickname }}</a></h5>
                <span class="member-title ellipsis">{{ latestMember.title }}</span>
              </div>
            </li>
            {% endfor %}
          {% else %}
            <div class="empty">无会员记录</div>
          {% endif %}
        </ul>
      </div>
    </div>
    {% block main_body %}{% endblock %}

  </div>
</div>

{% endblock %}
